package com.nikkerball.apps.darkhorse.model.base;

import com.nikkerball.apps.darkhorse.model.change.ChangeEvent;
import com.nikkerball.apps.darkhorse.model.change.ChangeValue;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.util.List;

/**
 * Represents an object that contains a value
 *
 * @author marius (created on 2010-12-09)
 */
@MappedSuperclass
public class ValueObject extends TouchableObject {

    // ----- class fields -----

    private static final int VALUE_COLUMN_LENGTH = 1024;

    // ----- instance fields -----

    private String value;

    // ----- public methods -----

    @Transient
    public List<ChangeValue> getChangeValues(ChangeEvent changeEvent) {
        List<ChangeValue> changeValues = super.getChangeValues(changeEvent);
        changeValues.add(new ChangeValue("value", getValue(), changeEvent));
        return changeValues;
    }

    @Column(nullable = false, length = VALUE_COLUMN_LENGTH)
    public String getValue() {
        return this.value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
